/// @tags:
#include <cctype>
#include <cstdio>
#include <cstring>

namespace BlueQuantum {

typedef long long ll;

int const N = 1e2 + 5, mod = 1e9 + 7;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

ll n;
bool pr[N], nf[N];
int m, p;

struct Matrix {
  ll a[N][N];

  Matrix() { memset(a, 0, sizeof(a)); }

  inline Matrix operator*(Matrix const &b) const {
    Matrix res;
    for (int i = 1; i < N; ++i) {
      for (int j = 1; j < N; j++) {
        for (int k = 1; k < N; k++) {
          res.a[i][j] += a[i][k] * b.a[k][j] % mod;
          if (res.a[i][j] >= mod) res.a[i][j] -= mod;
        }
      }
    }
    return res;
  }
} a, f;

inline int main() {
  read(n);
  for (int i = 1; i < N - 1; ++i) a.a[i + 1][i] = 1;
  read(m);
  for (int i = 1, x; i <= m; ++i) pr[read(x)] = true;
  read(m);
  for (int i = 1, x; i <= m; ++i) nf[read(x)] = true;
  f.a[1][N - 1] = 1;
  for (int i = 1; i < N - 1; ++i)
    if (pr[i] && nf[i]) a.a[N - 1 - i + 1][N - 1] = 1;
  while (n) {
    if (n & 1) f = f * a;
    a = a * a;
    n >>= 1;
  }
  printf("%lld", f.a[1][N - 1]);
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P5343 【XR-1】分块.in", "r", stdin);
  freopen("P5343 【XR-1】分块.out", "w", stdout);
#endif
#endif

  return BlueQuantum::main();
}